package ai

import (
	"fmt"

	jobx "gobase/http_work_flow/label_center/ai/job"
	"gobase/rpcx_work_flow/rpcx_label_center"
)

// 数据转绘制
func Data2Safety(value *jobx.RespSafety) (_frame rpcx_label_center.Frame, _err error) {
	var metas = make([]rpcx_label_center.Meta, 0)
	if len(value.ResultValue.ResultDetail.ResultItems) == 0 {
		_err = fmt.Errorf("安全帽检测，没有结果")
		return
	}
	for _, v := range value.ResultValue.ResultDetail.ResultItems {
		var meta = rpcx_label_center.Meta{
			X:           int64(v.LeftTopX),
			Y:           int64(v.LeftTopY),
			Remark:      "安全帽识别(省)",
			StrokeStyle: "rgb(255,0,0)",
			TypeId:      rpcx_label_center.IdScheme未戴安全帽,
			// ProtoWidth:  1920,
			// ProtoHeight: 1080,
			Rect: &rpcx_label_center.Rect{
				Width:  int64(v.RightBottomX - v.LeftTopX),
				Height: int64(v.RightBottomY - v.LeftTopY),
				Text:   value.ResultValue.ResultDetail.ResultDesc,
				Center: false,
			},
		}
		switch value.ResultValue.ResultDetail.ResultDesc {
		case "011_wz_xwwz_wdaqm":
			meta.Rect.Text = "未戴安全帽"
		default:
		}
		metas = append(metas, meta)
	}
	_frame = rpcx_label_center.Frame{
		Metas: &metas,
		AbsoluteTime: &rpcx_label_center.AbsoluteTime{
			CenterUnixMs: 0, //抽图毫秒时间
			DurationMs:   2000,
		},
	}
	return
}
